<template>
  <div class="Group">
    <H2>团购管理</H2>
    <div class="top_inputl">
      <div class="tab-inp">
        <div class="input-tr">
        <b>搜索:</b>
        <el-input v-model="input" placeholder="关键字"></el-input>
      </div>
      <!-- 请选者省份 -->
      <el-select v-model="value" placeholder="请选择">
        <el-option
          v-for="item in tableData"
          :key="item.value"
          :label="item.name"
          :value="item.value"
        >
          <span style="float: left">{{ item.name }}</span>
        </el-option>
      </el-select>
      <!-- 请选者城市 -->
      <el-select v-model="valu" placeholder="请选择城市">
        <el-option
          v-for="item in tableData"
          :key="item.valu"
          :label="item.city"
          :value="item.valu"
        >
          <span style="float: left">{{ item.city }}</span>
        </el-option>
      </el-select>
      <!-- 请选者区县 -->
      <el-select v-model="val" placeholder="请选择城市">
        <el-option
          v-for="item in tableData"
          :key="item.val"
          :label="item.city"
          :value="item.val"
        >
          <span style="float: left">{{ item.city }}</span>
        </el-option>
      </el-select>
      <el-select v-model="val" placeholder="请选择城市">
        <el-option
          v-for="item in tableData"
          :key="item.val"
          :label="item.city"
          :value="item.val"
        >
          <span style="float: left">{{ item.city }}</span>
        </el-option>
      </el-select>
      <el-select v-model="val" placeholder="请选择城市">
        <el-option
          v-for="item in tableData"
          :key="item.val"
          :label="item.city"
          :value="item.val"
        >
          <span style="float: left">{{ item.city }}</span>
        </el-option>
      </el-select>
      <!-- 搜索 -->
      <el-button type="inof" @click="kwywor">查询</el-button>
      </div>
    </div>
    <!-- tab表格 -->
    <el-table :data="tableData" border 
     :header-cell-style="{background:'#efefef',color:'#606266'}"
    >
      <el-table-column prop="id" label="序号" width="60"> </el-table-column>
      <el-table-column prop="price" label="图片" width="130"> </el-table-column>
      <el-table-column prop="name" label="楼盘名称"> </el-table-column>
      <el-table-column prop="city" label="发起人"> </el-table-column>
      <el-table-column prop="time" label="起始时间"> </el-table-column>
      <el-table-column prop="" label="状态"> 
        开关
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="120">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="deleteRow(scope.row.id)"
            type="text"
            size="small"
          >
            移除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      tableData: [],
      input: "",
      value: "",
      valu: "",
      val: "",
    };
  },
  created() {
    axios.get("http://127.0.0.1:7001/getList").then((res) => {
      console.log("res.....", res.data.data);
      this.tableData = res.data.data;
    });
  },
  methods: {
    deleteRow(id) {
       axios.delete(`http://127.0.0.1:7001/delete/${id}`).then((res) => {
        this.$router.go(0);
        console.log("id.;.;.;",id)
      });
    },
    kwywor() {
      axios
        .get(`http://127.0.0.1:7001/getList/?keyword=${this.input}`)
        .then((res) => {
          this.tableData = res.data.data;
        });
    },
  },
};
</script>

<style>
.input-tr {
  display: flex;
  align-items: center;
}
span {
  text-align: center;
  width: 45px;
}
</style>
